{{>licenseInfo}}

package {{packagename}};

{{#singlemodel}}
{{#model}}
{{#isEnum}}
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

/**
 * {{#description}}{{{description}}}{{/description}}
 */
public enum {{#vendorExtensions.x-classname}}{{vendorExtensions.x-classname}}{{/vendorExtensions.x-classname}}{{^vendorExtensions.x-classname}}{{classname}}{{/vendorExtensions.x-classname}} {
    {{#allowableValues}}
    {{#enumVars}}
    {{{name}}}({{{value}}}){{^-last}},{{/-last}}{{#-last}};{{/-last}}
    {{/enumVars}}
    {{/allowableValues}}

    private final {{{datatype}}} value;

    private {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{#vendorExtensions.x-classname}}{{vendorExtensions.x-classname}}{{/vendorExtensions.x-classname}}{{^vendorExtensions.x-classname}}{{classname}}{{/vendorExtensions.x-classname}}{{/datatypeWithEnum}}({{{datatype}}} value) {
        this.value = value;
    }

    @JsonValue
    public {{{datatype}}} value() {
        return value;
    }

    @JsonCreator
    public static {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{#vendorExtensions.x-classname}}{{vendorExtensions.x-classname}}{{/vendorExtensions.x-classname}}{{^vendorExtensions.x-classname}}{{classname}}{{/vendorExtensions.x-classname}}{{/datatypeWithEnum}} value(String v) {
        if (v == null || v.isEmpty()) return null;
        for ({{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{#vendorExtensions.x-classname}}{{vendorExtensions.x-classname}}{{/vendorExtensions.x-classname}}{{^vendorExtensions.x-classname}}{{classname}}{{/vendorExtensions.x-classname}}{{/datatypeWithEnum}} t : {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{#vendorExtensions.x-classname}}{{vendorExtensions.x-classname}}{{/vendorExtensions.x-classname}}{{^vendorExtensions.x-classname}}{{classname}}{{/vendorExtensions.x-classname}}{{/datatypeWithEnum}}.values()) {
            if (String.valueOf(t.value).equals(v)) {
                return t;
            }
        }
        return null;
    }
}
{{/isEnum}}
{{^isEnum}}
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.ToString;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import com.huawei.openstack4j.model.ModelEntity;
import com.huawei.openstack4j.openstack.common.ListResult;

import java.util.List;

/**
 * {{#description}}{{{description}}}{{/description}}
 */
@Getter
@ToString
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class {{#vendorExtensions.x-classname}}{{vendorExtensions.x-classname}}{{/vendorExtensions.x-classname}}{{^vendorExtensions.x-classname}}{{classname}}{{/vendorExtensions.x-classname}} implements ModelEntity {
    /**
     * serialVersionUID
     */
    private static final long serialVersionUID = 1L;
    {{#vars}}
    {{#isEnum}}

    /**
    * {{#description}}{{{description}}}{{/description}}
    */
    public enum {{{datatypeWithEnum}}} {
        {{#allowableValues}}
        {{#enumVars}}
        {{{name}}}({{{value}}}){{^-last}},{{/-last}}{{#-last}};{{/-last}}
        {{/enumVars}}
        {{/allowableValues}}

        private final {{{datatype}}} value;

        private {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{#vendorExtensions.x-classname}}{{vendorExtensions.x-classname}}{{/vendorExtensions.x-classname}}{{^vendorExtensions.x-classname}}{{classname}}{{/vendorExtensions.x-classname}}{{/datatypeWithEnum}}({{{datatype}}} value) {
            this.value = value;
        }

        @JsonValue
        public {{{datatype}}} value() {
            return value;
        }

        @JsonCreator
        public static {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{#vendorExtensions.x-classname}}{{vendorExtensions.x-classname}}{{/vendorExtensions.x-classname}}{{^vendorExtensions.x-classname}}{{classname}}{{/vendorExtensions.x-classname}}{{/datatypeWithEnum}} value(String v) {
            if (v == null || v.isEmpty()) return null;
            for ({{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{#vendorExtensions.x-classname}}{{vendorExtensions.x-classname}}{{/vendorExtensions.x-classname}}{{^vendorExtensions.x-classname}}{{classname}}{{/vendorExtensions.x-classname}}{{/datatypeWithEnum}} t : {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{#vendorExtensions.x-classname}}{{vendorExtensions.x-classname}}{{/vendorExtensions.x-classname}}{{^vendorExtensions.x-classname}}{{classname}}{{/vendorExtensions.x-classname}}{{/datatypeWithEnum}}.values()) {
                if (String.valueOf(t.value).equals(v)) {
                    return t;
                }
            }
            return null;
        }
    }
    {{/isEnum}}

    /**
     * {{{description}}}
     */
    @JsonProperty("{{baseName}}")
    private {{{datatypeWithEnum}}} {{name}};
    {{/vars}}
    {{/isEnum}}
    {{/model}}
    {{/singlemodel}}
    {{#alloperations}}
    {{#operations}}
    {{#operation}}
    {{#vendorExtensions.isExtractInfo}}

    /**
     * {{{summary}}}
     */
    public static class {{returnBaseType}}s extends ListResult<{{returnBaseType}}> {
        /**
        * serialVersionUID
        */
        private static final long serialVersionUID = 1L;

        protected List<{{returnBaseType}}> list;

        @Override
        public List<{{returnBaseType}}> value() {
            return list;
        }
    }
    {{/vendorExtensions.isExtractInfo}}
    {{/operation}}
    {{/operations}}
    {{/alloperations}}
}
